﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using TCG.Engine.Core;
using TCG.Engine.Tests.Mocks;

namespace TCG.Engine.Tests
{
    public class MatchTestBase
    {
        protected Match game;

        public void ConstructHand(Player player, params string[] cards)
        {
            player.Hand.ForEach(c => player.Deck.AddCard(c));
            player.Hand.Clear();
            foreach (var c in cards)
            {
                player.Hand.Add(player.Deck.GetCard(c));
            }
        }

        public void Turn(params string[] moves)
        {
            Func<Player, Card>[] ms = new Func<Player, Card>[moves.Length];
            for (int i = 0; i < moves.Length; i++)
            {
                var k = i;
                ms[i] = p => p.Hand.First(c => c.Info.Id == moves[k]);
            }
            Turn(ms);
        }

        public void Turn(params Func<Player, Card>[] moves)
        {
            var i = game.ActivePlayer.Interaction as DummyInteraction;
            i.Clear();
            foreach (var m in moves)
            {
                i.Move(m);
            }
            game.PlayTurn();
        }
    }
}
